home *** CD-ROM | disk | FTP | other *** search
/ Merciful 5 / Merciful - Disc 5.iso / software / p / pcqpascalv1.2d.lha / Include / Devices / CD.i < prev    next >
Text File  |  1997-05-06  |  14KB  |  313 lines

  1.   { Only V40+ }
  2.  
  3.   {    cd.device include file    }
  4.  
  5. {$I "Include:Exec/types.i"}
  6. {$I "Include:Exec/Nodes.i"}
  7.  
  8. {*************************************************************************
  9.  *                                                                        *
  10.  *   CD Commands                                                          *
  11.  *                                                                        *
  12.  *************************************************************************}
  13.  
  14. const
  15.    CD_RESET          =   1;
  16.    CD_READ           =   2;
  17.    CD_WRITE          =   3;
  18.    CD_UPDATE         =   4;
  19.    CD_CLEAR          =   5;
  20.    CD_STOP           =   6;
  21.    CD_START          =   7;
  22.    CD_FLUSH          =   8;
  23.    CD_MOTOR          =   9;
  24.    CD_SEEK           =  10;
  25.    CD_FORMAT         =  11;
  26.    CD_REMOVE         =  12;
  27.    CD_CHANGENUM      =  13;
  28.    CD_CHANGESTATE    =  14;
  29.    CD_PROTSTATUS     =  15;
  30.  
  31.    CD_GETDRIVETYPE   =  18;
  32.    CD_GETNUMTRACKS   =  19;
  33.    CD_ADDCHANGEINT   =  20;
  34.    CD_REMCHANGEINT   =  21;
  35.    CD_GETGEOMETRY    =  22;
  36.    CD_EJECT          =  23;
  37.  
  38.  
  39.    CD_INFO           =  32;
  40.    CD_CONFIG         =  33;
  41.    CD_TOCMSF         =  34;
  42.    CD_TOCLSN         =  35;
  43.  
  44.    CD_READXL         =  36;
  45.  
  46.    CD_PLAYTRACK      =  37;
  47.    CD_PLAYMSF        =  38;
  48.    CD_PLAYLSN        =  39;
  49.    CD_PAUSE          =  40;
  50.    CD_SEARCH         =  41;
  51.  
  52.    CD_QCODEMSF       =  42;
  53.    CD_QCODELSN       =  43;
  54.    CD_ATTENUATE      =  44;
  55.  
  56.    CD_ADDFRAMEINT    =  45;
  57.    CD_REMFRAMEINT    =  46;
  58.  
  59.  
  60. {*************************************************************************
  61.  *                                                                        *
  62.  *   Device Driver Error Codes                                            *
  63.  *                                                                        *
  64.  *************************************************************************}
  65.  
  66.    CDERR_OPENFAIL     =  (-1); { device/unit failed to open   }
  67.    CDERR_ABORTED      =  (-2); { request terminated early             }
  68.    CDERR_NOCMD        =  (-3); { command not supported by device      }
  69.    CDERR_BADLENGTH    =  (-4); { invalid length (IO_LENGTH/IO_OFFSET) }
  70.    CDERR_BADADDRESS   =  (-5); { invalid address (IO_DATA misaligned) }
  71.    CDERR_UNITBUSY     =  (-6); { device opens ok, but unit is busy    }
  72.    CDERR_SELFTEST     =  (-7); { hardware failed self-test            }
  73.  
  74.    CDERR_NotSpecified   = 20;   { general catchall                     }
  75.    CDERR_NoSecHdr       = 21;   { couldn't even find a sector          }
  76.    CDERR_BadSecPreamble = 22;   { sector looked wrong                  }
  77.    CDERR_BadSecID       = 23;   { ditto                                }
  78.    CDERR_BadHdrSum      = 24;   { header had incorrect checksum        }
  79.    CDERR_BadSecSum      = 25;   { data had incorrect checksum          }
  80.    CDERR_TooFewSecs     = 26;   { couldn't find enough sectors         }
  81.    CDERR_BadSecHdr      = 27;   { another "sector looked wrong"        }
  82.    CDERR_WriteProt      = 28;   { can't write to a protected disk      }
  83.    CDERR_NoDisk         = 29;   { no disk in the drive                 }
  84.    CDERR_SeekError      = 30;   { couldn't find track 0                }
  85.    CDERR_NoMem          = 31;   { ran out of memory                    }
  86.    CDERR_BadUnitNum     = 32;   { asked for a unit > NUMUNITS          }
  87.    CDERR_BadDriveType   = 33;   { not a drive cd.device understands    }
  88.    CDERR_DriveInUse     = 34;   { someone else allocated the drive     }
  89.    CDERR_PostReset      = 35;   { user hit reset; awaiting doom        }
  90.    CDERR_BadDataType    = 36;   { data on disk is wrong type   }
  91.    CDERR_InvalidState   = 37;   { invalid cmd under current conditions }
  92.  
  93.    CDERR_Phase          = 42;   { illegal or unexpected SCSI phase     }
  94.    CDERR_NoBoard        = 50;   { open failed for non-existant board   }
  95.  
  96.  
  97.  
  98. {*************************************************************************
  99.  *                                                                        *
  100.  * Configuration                                                          *
  101.  *                                                                        *
  102.  *       The drive is configured by TagList items defined as follows:     *
  103.  *                                                                        *
  104.  *************************************************************************}
  105.  
  106.    TAGCD_PLAYSPEED        = $0001;
  107.    TAGCD_READSPEED        = $0002;
  108.    TAGCD_READXLSPEED      = $0003;
  109.    TAGCD_SECTORSIZE       = $0004;
  110.    TAGCD_XLECC            = $0005;
  111.    TAGCD_EJECTRESET       = $0006;
  112.  
  113.  
  114. {*************************************************************************
  115.  *                                                                        *
  116.  * Information                                                            *
  117.  *                                                                        *
  118.  *      Information/Status structure describes current speed settings     *
  119.  *      for read and play commands, sector size, audio attenuation        *
  120.  *      precision, and drive status.                                      *
  121.  *                                                                        *
  122.  *************************************************************************}
  123.  
  124. Type
  125.  CDInfo = Record
  126.                                         {                                Default     }
  127.     PlaySpeed,                          { Audio play speed       (75)        }
  128.     ReadSpeed,                          { Data-rate of CD_READ command   (Max)       }
  129.     ReadXLSpeed,                        { Data-rate of CD_READXL command (75)        }
  130.     SectorSize,                         { Number of bytes per sector     (2048)      }
  131.     XLECC,                              { CDXL ECC enabled/disabled                  }
  132.     EjectReset : WORD;                  { Reset on eject enabled/disabled            }
  133.     Reserved1 : Array[0..3] of WORD;    { Reserved for future expansion              }
  134.     MaxSpeed,                           { Maximum speed drive can handle (75, 150)   }
  135.     AudioPrecision,                     { 0 = no attenuator, 1 = mute only,          }
  136.                                         { other = (# levels - 1)                     }
  137.     Status : WORD;                      { See flags below                            }
  138.     Reserved2 : Array[0..3] of WORD;    { Reserved for future expansion              }
  139.  end;
  140.  CDInfoPtr = ^CDInfo;
  141.  
  142.  
  143. const
  144. { Flags for Status }
  145.  
  146.    CDSTSB_CLOSED    = 0; { Drive door is closed                        }
  147.    CDSTSB_DISK      = 1; { A disk has been detected                    }
  148.    CDSTSB_SPIN      = 2; { Disk is spinning (motor is on)              }
  149.    CDSTSB_TOC       = 3; { Table of contents read.  Disk is valid.     }
  150.    CDSTSB_CDROM     = 4; { Track 1 contains CD-ROM data                }
  151.    CDSTSB_PLAYING   = 5; { Audio is playing                            }
  152.    CDSTSB_PAUSED    = 6; { Pause mode (pauses on play command)         }
  153.    CDSTSB_SEARCH    = 7; { Search mode (Fast Forward/Fast Reverse)     }
  154.    CDSTSB_DIRECTION = 8; { Search direction (0 = Forward, 1 = Reverse) }
  155.  
  156.    CDSTSF_CLOSED    = $0001;
  157.    CDSTSF_DISK      = $0002;
  158.    CDSTSF_SPIN      = $0004;
  159.    CDSTSF_TOC       = $0008;
  160.    CDSTSF_CDROM     = $0010;
  161.    CDSTSF_PLAYING   = $0020;
  162.    CDSTSF_PAUSED    = $0040;
  163.    CDSTSF_SEARCH    = $0080;
  164.    CDSTSF_DIRECTION = $0100;
  165.  
  166.  
  167. { Modes for CD_SEARCH }
  168.  
  169.    CDMODE_NORMAL  = 0;         { Normal play at current play speed    }
  170.    CDMODE_FFWD    = 1;         { Fast forward play (skip-play forward)}
  171.    CDMODE_FREV    = 2;         { Fast reverse play (skip-play reverse)}
  172.  
  173.  
  174. {*************************************************************************
  175.  *                                                                        *
  176.  * Position Information                                           *
  177.  *                                                                        *
  178.  *      Position information can be described in two forms: MSF and LSN   *
  179.  *      form.  MSF (Minutes, Seconds, Frames) form is a time encoding.    *
  180.  *      LSN (Logical Sector Number) form is frame (sector) count.         *
  181.  *      The desired form is selected using the io_Flags field of the      *
  182.  *      IOStdReq structure.  The flags and the union are described        *
  183.  *      below.                                                            *
  184.  *                                                                        *
  185.  *************************************************************************}
  186.  
  187. Type
  188.  RMSF = Record
  189.     Reserved,       { Reserved (always zero) }
  190.     Minute,         { Minutes (0-72ish)      }
  191.     Second,         { Seconds (0-59)         }
  192.     Frame  : WORD;  { Frame   (0-74)         }
  193.  end;
  194.  RMSFPtr = ^RMSF;
  195.  
  196.  LSNMSF = Record
  197.     MSF     : RMSF;         { Minute, Second, Frame  }
  198.     LSN     : Integer;      { Logical Sector Number  }
  199.  end;
  200.  LSNMSFPtr = ^LSNMSF;
  201.  
  202.  
  203. {*************************************************************************
  204.  *                                                                        *
  205.  * CD Transfer Lists                                                      *
  206.  *                                                                        *
  207.  *      A CDXL node is a double link node; however only single linkage    *
  208.  *      is used by the device driver.  If you wish to construct a         *
  209.  *      transfer list manually, it is only neccessary to define the       *
  210.  *      mln_Succ pointer of the MinNode.  You may also use the Exec       *
  211.  *      list functions by defining a List or MinList structure and by     *
  212.  *      using the AddHead/AddTail functions to create the list.  This     *
  213.  *      will create a double-linked list.  Although a double-linked       *
  214.  *      list is not required by the device driver, you may wish use it    *
  215.  *      for your own purposes.  Don't forget to initialize the            *
  216.  *      the List/MinList before using it!                                 *
  217.  *                                                                        *
  218.  *************************************************************************}
  219.  
  220.  CDXL = Record
  221.     Node              : MinNode;       { double linkage                  }
  222.     Buffer            : Address;       { data destination (word aligned) }
  223.     Length,                            { must be even # bytes            }
  224.     Actual            : Integer;       { bytes transferred               }
  225.     IntData           : Address;       { interrupt server data segment   }
  226.     IntCode           : Address;       { interrupt server code entry     }
  227.  end;
  228.  CDXLPtr = ^CDXL;
  229.  
  230.  
  231. {*************************************************************************
  232.  *                                                                        *
  233.  * CD Table of Contents                                           *
  234.  *                                                                        *
  235.  *      The CD_TOC command returns an array of CDTOC entries.             *
  236.  *      Entry zero contains summary information describing how many       *
  237.  *      tracks the disk has and the play-time of the disk.                *
  238.  *      Entries 1 through N (N = Number of tracks on disk) contain        *
  239.  *      information about the track.                                      *
  240.  *                                                                        *
  241.  *************************************************************************}
  242.  
  243.  TOCSummary = Record
  244.     FirstTrack,            { First track on disk (always 1)            }
  245.     LastTrack   : Byte;    { Last track on disk                        }
  246.     LeadOut     : LSNMSF;  { Beginning of lead-out track (end of disk) }
  247.  end;
  248.  TOCSummaryPtr = ^TOCSummary;
  249.  
  250.  
  251.  TOCEntry = Record
  252.     CtlAdr,             { Q-Code info                  }
  253.     Track  : Byte;      { Track number                 }
  254.     Position  : LSNMSF; { Start position of this track }
  255.  end;
  256.  TOCEntryPtr = ^TOCEntry;
  257.  
  258.  
  259.  CDTOC = Record
  260.     Summary  : TOCSummary;  { First entry (0) is summary information }
  261.     Entry    : TOCEntry;    { Entries 1-N are track entries          }
  262.  end;
  263.  CDTOCPtr = ^CDTOC;
  264.  
  265.  
  266.  
  267. {*************************************************************************
  268.  *                                                                        *
  269.  * Q-Code Packets                                                         *
  270.  *                                                                        *
  271.  *      Q-Code packets are only returned when audio is playing.   *
  272.  *      Currently, only position packets are returned (ADR_POSITION)      *
  273.  *      The other ADR_ types are almost never encoded on the disk         *
  274.  *      and are of little use anyway.  To avoid making the QCode          *
  275.  *      structure a union, these other ADR_ structures are not defined.   *
  276.  *                                                                        *
  277.  *************************************************************************}
  278.  
  279.  QCode = Record
  280.   CtlAdr,               { Data type / QCode type           }
  281.   Track,                { Track number             }
  282.   Index,                { Track subindex number            }
  283.   Zero : Byte;          { The "Zero" byte of Q-Code packet }
  284.   TrackPosition,        { Position from start of track     }
  285.   DiskPosition  : LSNMSF;  { Position from start of disk      }
  286.  end;
  287.  QCodePtr = ^QCode;
  288.  
  289. const
  290.    CTLADR_CTLMASK = $F0;   { Control field }
  291.  
  292.    CTL_CTLMASK    = $D0;   { To be ANDed with CtlAdr before compared  }
  293.  
  294.    CTL_2AUD       = $00;   { 2 audio channels without preemphasis     }
  295.    CTL_2AUDEMPH   = $10;   { 2 audio channels with preemphasis        }
  296.    CTL_4AUD       = $80;   { 4 audio channels without preemphasis     }
  297.    CTL_4AUDEMPH   = $90;   { 4 audio channels with preemphasis        }
  298.    CTL_DATA       = $40;   { CD-ROM Data                              }
  299.  
  300.    CTL_COPYMASK   = $20;   { To be ANDed with CtlAdr before compared  }
  301.  
  302.    CTL_COPY       = $20;   { When true, this audio/data can be copied }
  303.  
  304.    CTLADR_ADRMASK = $0F;   { Address field                            }
  305.  
  306.    ADR_POSITION   = $01;   { Q-Code is position information   }
  307.    ADR_UPC        = $02;   { Q-Code is UPC information (not used)     }
  308.    ADR_ISRC       = $03;   { Q-Code is ISRC (not used)                }
  309.    ADR_HYBRID     = $05;   { This disk is a hybrid disk               }
  310.  
  311.  
  312.  
  313.